/**
 * DesViewController
 * @Chunning.Xu
 * 2011 Nov 23, 2011 8:42:07 PM
 **/
package com.lux.product.controllers
{
	import com.greensock.TweenLite;
	import com.greensock.easing.Cubic;
	import com.lux.product.views.GradientTextView;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	
	public class DesViewController extends LuxViewController
	{
		//START.
		
		private var currentTextView:Sprite;
		
		public function DesViewController(view:Sprite)
		{
			super(view);
		}
		
		public function changeCopy(title:String,des:String):void
		{
			
			var tempView:Sprite = currentTextView;
			
			currentTextView = new DesItemViewUI;
			var txtDes:TextField = currentTextView.getChildByName("txtDes") as TextField;
			txtDes.autoSize = TextFieldAutoSize.LEFT;
			txtDes.text = des;
				
			var titleView:GradientTextView = new GradientTextView;
			titleView.text = title;
			titleView.x+=0.5;
			titleView.y+=0.5;
			currentTextView.addChild(titleView);
			
			var titleView2:GradientTextView = new GradientTextView;
			titleView2.text = title;
			currentTextView.addChild(titleView2);
				
			this.view.addChild(currentTextView);
			
			if(tempView != null)
			{
			  	TweenLite.killTweensOf(tempView);
				currentTextView.alpha = 0;
				TweenLite.to(tempView,0.5,{alpha:0,ease:Cubic.easeInOut,onComplete:easeOutCompleteHandler,onCompleteParams:[tempView]});
				TweenLite.to(currentTextView,0.5,{alpha:1.0,ease:Cubic.easeInOut,delay:0.2});
			}
		}

		private function easeOutCompleteHandler(view:Sprite):void
		{
			if(this.view.contains(view))
				this.view.removeChild(view);
		}
		
		public function get contentHeight():Number
		{
			var txtDes:TextField = currentTextView.getChildByName("txtDes") as TextField;
			return txtDes.y + txtDes.height;
		}
		
		//END
	}
}